package dev.caobaoqi6040.backend.modules.ai.service.impl;

import dev.caobaoqi6040.backend.modules.ai.domain.response.MCPToolINFOVo;
import dev.caobaoqi6040.backend.modules.ai.service.MCPService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.mcp.SyncMcpToolCallbackProvider;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * MCPServiceImpl
 *
 * @author caobaoqi6040
 * @since 2025/10/9 16:08
 */
@Service
@RequiredArgsConstructor
public class MCPServiceImpl implements MCPService {

	private final SyncMcpToolCallbackProvider provider;

	@Override
	public List<MCPToolINFOVo> listTool() {
		return Arrays.stream(provider.getToolCallbacks())
			.map(ToolCallback::getToolDefinition)
			.map(def -> new MCPToolINFOVo(
				def.name(),
				def.description()
			))
			.toList();
	}

}

